#include "../include/head.h"

int recvn(int netfd,void* buf,long len,long* pProcessed)
{
    long processed = 0;
    char*p =(char*)buf;
    while(processed<len)
    {
        int ret = read(netfd,p+(processed),len-(processed));
        processed += ret;

        if(ret==0)
        {
            if(pProcessed!=NULL){*pProcessed = processed;}
            return -1;
        }
    }
    if(pProcessed!=NULL){*pProcessed = processed;}
    return 0;
}
// int ErrCheck_ClientClose(int ret,int netfd,int epfd,pthread_mutex_t* mtx,Client_info* clientInfo)
// {
//     if(ret==-1)
//     {
//         pthread_mutex_lock(mtx);
//         clientInfo[netfd].belongs_to_userid=-1;
//         clientInfo[netfd].now_path_id = -1;
//         pthread_mutex_unlock(mtx);
//         epollDel(epfd,netfd);
//         printf("%d用户已退出！\n", netfd);
//         close(netfd);
//         return 0;
//     }
//     return 1;
// }